package com.nakaikensuke.SNE;

import java.util.Iterator;

public class EntriesIterator implements Iterator<DirEntry> {

	static {
		System.loadLibrary("direntries");
	}
	
	private native boolean open(String path);
	private native DirEntry readdir(String encode);
	private native void close();
	
	@Override
	public boolean hasNext() {
		return true;
	}

	@Override
	public DirEntry next() {
		return readdir(_encode);
	}

	@Override
	public void remove() {
	}
	
	private String _path = "";
	private String _encode = "";
	
	public EntriesIterator(String path, String encode) {
		_encode = encode;
		_path = path;
		boolean opened = open(path);
		if(!opened)
			throw new RuntimeException("open failed");
	}

	public void Dispose() {
		this.close();
	}
}
